﻿Imports System.Data.SqlClient
Public Class clsPeriodoFonacot
    Private mintIdFonacot As Integer
    Private mintMes As Integer
    Private mintDel As Integer
    Private mintAl As Integer
    Private mintAnio As Integer
    Private mstrStatus As String
    Public Property IdFonacot() As Integer
        Get
            Return mintIdFonacot
        End Get
        Set(ByVal value As Integer)
            mintIdFonacot = value
        End Set
    End Property
    Public Property Mes() As Integer
        Get
            Return mintMes
        End Get
        Set(ByVal value As Integer)
            mintMes = value
        End Set
    End Property
    Public Property Del() As Integer
        Get
            Return mintDel
        End Get
        Set(ByVal value As Integer)
            mintDel = value
        End Set
    End Property
    Public Property Al() As Integer
        Get
            Return mintAl
        End Get
        Set(ByVal value As Integer)
            mintAl = value
        End Set
    End Property
    Public Property Anio() As Integer
        Get
            Return mintAnio
        End Get
        Set(ByVal value As Integer)
            mintAnio = value
        End Set
    End Property
    Public Property Status() As String
        Get
            Return mstrStatus
        End Get
        Set(ByVal value As String)
            mstrStatus = value
        End Set
    End Property

    Public Sub New()
        mintIdFonacot = 0
        mintMes = 0
        mintDel = 0
        mintAl = 0
        mintAnio = 0
        mstrStatus = ""
    End Sub
    Public Sub Borrar()
        Call SetSqlCitra("Delete From PeriodoFonacot Where IdFonacot = " & IdFonacot)
    End Sub
    Public Sub Insertar()
        Dim sql As String = "Insert Into PeriodoFonacot (" & _
                            "IdFonacot," & _
                            "Mes," & _
                            "Del," & _
                            "Al," & _
                            "Anio," & _
                            "Status)" & _
                            "VALUES (" & _
                            "@IdFonacot," & _
                            "@Mes," & _
                            "@Del," & _
                            "@Al," & _
                            "@Anio," & _
                            "@Status)"


        Dim cnConn As New SqlConnection
        cnConn.ConnectionString = CitraConnection

        Dim Command As New SqlCommand(sql, cnConn)

        Command.Parameters.AddWithValue("IdFonacot", mintIdFonacot)
        Command.Parameters.AddWithValue("Mes", mintMes)
        Command.Parameters.AddWithValue("Del", mintDel)
        Command.Parameters.AddWithValue("Al", mintAl)
        Command.Parameters.AddWithValue("Anio", mintAnio)
        Command.Parameters.AddWithValue("Status", mstrStatus)

        cnConn.Open()
        Dim RowsAffected As Integer = Command.ExecuteNonQuery

        If RowsAffected > 0 Then
            cnConn.Close()
        Else
            MsgBox("No fue posible insertar el mes " & mintMes, MsgBoxStyle.Exclamation, "Aviso")
            If cnConn.State = ConnectionState.Open Then
                cnConn.Close()
            End If
        End If
    End Sub
End Class
